package cn.icanci.test.resource;

import java.io.BufferedWriter;
import java.io.File;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import org.springframework.core.io.FileSystemResource;

/**
 * @author icanci
 * @date Created in 2021/02/17 20:12
 * @version 1.0
 */
public class ResourceDemo {
    public static void main(String[] args) throws Exception{
        FileSystemResource fileSystemResource = new FileSystemResource(
            "/Users/icanci/ideaProjects/Source/spring-framework-5.2.0.RELEASE/spring-context/src/main/java/cn/icanci/test/resource/test.txt");

		File file = fileSystemResource.getFile();
		System.out.println(file.isDirectory());
		System.out.println(file.length());
		OutputStream outputStream = fileSystemResource.getOutputStream();
		BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
		bufferedWriter.write("hello icanci \n");
		bufferedWriter.flush();
		outputStream.close();
		bufferedWriter.close();
	}
}
